import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
import { UserModel } from '@/module/user/user.model';

@Entity('RATE', {
  synchronize: false,
}) // 评分
@Index('RATE.biz_uuid&user_uuid', ['bizUuid', 'userUuid'], {
  unique: true,
})
export class RateModel extends BaseModel {
  @Column({
    comment: '业务uuid',
    type: 'uuid',
  })
  bizUuid: string;

  @Column({
    comment: '评分占比，1-100整数',
    type: 'smallint',
  })
  score: number;

  @Column({
    comment: '用户uuid',
    type: 'uuid',
  })
  userUuid: string;
  @ManyToOne(() => UserModel, {
    createForeignKeyConstraints: false,
  })
  @JoinColumn({
    name: 'user_uuid',
    referencedColumnName: 'uuid',
  })
  user: UserModel;
}
